//
//  XJWebViewController.m
//  XinJiangMall
//
//  Created by RaoBo on 2018/7/5.
//  Copyright © 2018年 Tzyang. All rights reserved.
//

#import "XJWebViewController.h"
#import <WebKit/WebKit.h>

//    关于我们
//http://192.168.31.177:8080/customer/agreement/about_us
//    配送规则
//http://192.168.31.177:8080/customer/agreement/distribution_management
//    《未来巴扎用户协议》
//http://192.168.31.177:8080/customer/agreement/agreement_setting
//    《未来巴扎充值协议》
//http://192.168.31.177:8080/customer/agreement/agreement_recharge

#define kAgreement @"http://192.168.31.177:8080/customer/agreement/"
#define kAbout_us @"about_us" //关于我们
#define kDistributionManagement @"distribution_management" //配送规则
#define kAgreementSetting @"agreement_setting" //用户协议
#define kAgreementRecharge @"agreement_setting" //充值协议


@interface XJWebViewController ()<UINavigationControllerDelegate,WKUIDelegate>
@property (nonatomic, strong) WKWebView *webView;

@end

@implementation XJWebViewController

#pragma mark - 二 生命周期
#pragma mark - 三 控制器


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
  WKWebView  *tempWebView = [[WKWebView alloc] initWithFrame:self.view.bounds];
    
    [self.view addSubview:tempWebView];
  
    tempWebView.UIDelegate = self;
//    tempWebView.navigationDelegate = self;
   
    [self.view addSubview:tempWebView];
    
    self.webView = tempWebView;
    

    NSString *navTitle = @"关于我们";
    NSString *urlStr = [NSString stringWithFormat:@"%@%@",kAgreement,kAbout_us];
    
    if (self.vcType == XJWebVCTypeDeliveryRule) {
        navTitle = @"配送规则";
        urlStr = [NSString stringWithFormat:@"%@%@",kAgreement,kDistributionManagement];

    }else if(self.vcType == XJWebVCTypeUSerProtocol) {
        navTitle = @"《未来巴扎用户协议》";
        urlStr = [NSString stringWithFormat:@"%@%@",kAgreement,kAgreementSetting];

    }else if(self.vcType == XJWebVCTypeAboutUs) {
        navTitle = @"关于我们";
        urlStr = [NSString stringWithFormat:@"%@%@",kAgreement,kAbout_us];
    }else if (self.vcType == XJWebVCTypeChargeProtocol) {
        navTitle = @"《未来巴扎充值协议》";
        urlStr = [NSString stringWithFormat:@"%@%@",kAgreement,kAgreementRecharge];
    }else {
        XJLog(@"没有");
        
        if ([NSString isEmptyString:self.url]) {
            urlStr = self.url;
        }
    }
    
    self.navigationItem.title = navTitle;
    
    NSURL *url = [NSURL URLWithString:urlStr];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [self.webView loadRequest:request];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
